// pages/weixiuHome/jiechedan/jiecheDetail/jiecheDetail.js
const request = require('../../../../../utils/request')
Page({
  data: {
    carInfo: {
      type: '',
      owner: '',
      ownerPhone: '',
      sender: '',
      senderPhone: ''
    },
    info: {
      chepai: '',
      danhao: '',
      cometime: '',
      licheng: '',
      xinagmu: '',
      waiguan: '',
      jiancha: '',
      weixiuxiang: '',
      peijianxiang: '',
      price: ''
    },
    id: '',
  },

  onLoad: function (options) {
    this.setData({
      id: options.id ? options.id : "",
    })
    if (options.id) {
      this.getDetail(options.id)
    }
  },
  getDetail(id) {
    wx.showLoading()
    request.get('repair_detail', { id })
      .then(res => {
        wx.hideLoading()
        if (res.data) {
          const data = res.data;
          this.setData({
            info: {
              chepai: data.chepai,
              danhao: data.danhao,
              cometime: data.sj,
              licheng: data.licheng,
              xinagmu: data.xinagmu,
              waiguan: data.waiguan,
              jiancha: data.free_jiance,
              weixiuxiang: data.weixiuxiang,
              peijianxiang: data.peijianxiang,
              price: data.total_price
            },
            carInfo: {
              type: data.chexing,
              owner: data.chezhu,
              ownerPhone: data.dianhua,
              sender: data.songxiuren,
              senderPhone: data.sxrdh
            },
          })
        }
      })
      .catch(error => {
        wx.showToast({
          icon: 'none',
          title: error.msg && error.msg
        })
      })
      .finally(_ => {
        
      })
  },


})
